unit upasCashDrawerCCOmain;
{$I LogOption.txt}

interface
//------------------------------------------------------------------------------
//  This module performs the necessary starup and housekeeping routines.
//    embed this module and all its supporting modules in you application.
//
//------------------------------------------------------------------------------
uses
  Classes,
  upasclientcashdrawer;

procedure initialize(Params: TStringList);
procedure finalize;

var
  CashDrawer: EOupasclientcashdrawer;

implementation
uses
  {$IFDEF LOGUNITTEST}
  AuditLog,
  {$ENDIF}
  upasparam,
  ParamUtil,
  INI_CCOCashDrawer;

{$IFDEF LOGUNITTEST}
const
  eventsource = 'upasCashDrawerCCOmain';
{$ENDIF}

procedure initialize(Params: TStringList);
var
  iniCashDrawer: EOIniCCOCashDrawer;
  sw_a: String;
begin
  {$IFDEF LOGUNITTEST}
  AuditLog.EventLog(AuditLog.etDUNIT, eventsource + '.initialize', '');
  {$ENDIF}

  // setup  CashDrawer1
  sw_a := ParamUtil.getSwitch(Params, upasparam.Switch_a);
  {$IFDEF LOGUNITTEST}
  AuditLog.EventLog(AuditLog.etDUNIT, eventsource + '.initialize', 'sw_a="' + sw_a + '"');
  {$ENDIF}

  iniCashDrawer := EOIniCCOCashDrawer.Create(sw_a);
  try
    {$IFDEF LOGUNITTEST}
    AuditLog.EventLog(AuditLog.etDUNIT, eventsource + '.initialize', 'DeviceName="' + iniCashDrawer.DeviceName + '"');
    {$ENDIF}

    CashDrawer := EOupasclientcashdrawer.Create(iniCashDrawer.DeviceName);
  finally
    iniCashDrawer.Free;
  end;
end;

procedure finalize;
begin
  CashDrawer.Free;

  {$IFDEF LOGUNITTEST}
  AuditLog.EventLog(AuditLog.etDUNIT, eventsource + '.finalize', '');
  {$ENDIF}
end;

end.
